# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=blackmagic
pkgver=1.9.1
pkgrel=1
pkgdesc='In application debugger for ARM Cortex microcontrollers'
arch=('loong64' 'x86_64')
url='https://github.com/blacksphere/blackmagic'
license=('GPL')
depends=('libusb' 'libftdi' 'libhidapi-libusb.so')
makedepends=('git' 'hidapi' 'python')
#             'arm-none-eabi-gcc')
source=("git+$url#tag=v$pkgver")
#        'git+https://github.com/libopencm3/libopencm3.git')
sha512sums=('SKIP')

#prepare() {
#  cd $pkgname
#
#  git submodule init
#  git config submodule.libopencm3.url "$srcdir"/libopencm3
#  git submodule update
#}

prepare() {
  sed -i 's| -Werror||' $pkgname/src/Makefile
}

build() {
  cd $pkgname

  make PROBE_HOST=hosted
}

package() {
  cd $pkgname

  install -Dm 755 src/blackmagic "$pkgdir"/usr/bin/blackmagic

  install -Dm 644 driver/*.rules -t "$pkgdir"/usr/share/solaar/udev-rules.d/
}

